const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin });
let input = [];

rl.on('line', line => input.push(line.trim()));
rl.on('close', () => {
  let idx = 0;
  const n = parseInt(input[idx++]);
  let good = 0, nice = 0;

  for (let t = 0; t < n; t++) {
    const m = parseInt(input[idx++]);
    const s = input[idx++];

    // 判断好字符串
    const isGood = (str) => {
      for (let i = 0; i + 1 < str.length; i++) {
        const a = str[i], b = str[i + 1];
        const ua = (a >= 'A' && a <= 'Z');
        const ub = (b >= 'A' && b <= 'Z');
        if (ua === ub) return false;
      }
      return true;
    };

    // 判断不错字符串
    let ok = false;
    if (isGood(s)) ok = true;
    else {
      for (let i = 0; i < m; i++) {
        const flipped =
          s.substring(0, i) +
          (s[i] === s[i].toUpperCase()
            ? s[i].toLowerCase()
            : s[i].toUpperCase()) +
          s.substring(i + 1);
        if (isGood(flipped)) {
          ok = true;
          break;
        }
      }
    }

    if (isGood(s)) good++;
    if (ok) nice++;
  }

  console.log(good + ' ' + nice);
});

